package com.googlecode.mapperdao

/**
 * float simple type
 */
case class FloatValue(value: Float) extends SimpleTypeValue[Float, FloatValue]
{
	def compareTo(o: FloatValue): Int = value.compare(o.value)
}

protected class FloatEntityOTM(table: String, soleColumn: String)
	extends Entity[Unit, NoId, FloatValue](table, classOf[FloatValue])
{
	val value = column(soleColumn) to (_.value)
	declarePrimaryKey(value)

	def constructor(implicit m: ValuesMap) = new FloatValue(value) with NoId
}

abstract class FloatEntityManyToManyBase[ID](table: String, soleColumn: String)
	extends Entity[ID, SurrogateIntId, FloatValue](table, classOf[FloatValue])
{
	val value = column(soleColumn) to (_.value)
}

class FloatEntityManyToManyAutoGenerated(table: String, pkColumn: String, soleColumn: String, sequence: Option[String] = None)
	extends FloatEntityManyToManyBase[Int](table, soleColumn)
{
	val id = key(pkColumn) sequence (sequence) autogenerated (_.id)

	def constructor(implicit m: ValuesMap) = new FloatValue(value) with SurrogateIntId
	{
		val id: Int = FloatEntityManyToManyAutoGenerated.this.id
	}
}

object FloatEntity
{
	def oneToMany(table: String, soleColumn: String) = new FloatEntityOTM(table, soleColumn)

	def manyToManyAutoGeneratedPK(table: String, pkColumn: String, soleColumn: String, sequence: Option[String] = None) = new FloatEntityManyToManyAutoGenerated(table, pkColumn, soleColumn, sequence)
}
